package org.deadline.service.baseapp;

import java.util.List;
import org.deadline.model.baseapp.NotificationResource;
import org.deadline.repository.baseapp.NotificationResourceRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class NotificationResourceServiceImpl implements NotificationResourceService {

	@Autowired
    NotificationResourceRepository notificationResourceRepository;

	public long countAllNotificationResources() {
        return notificationResourceRepository.count();
    }

	public void deleteNotificationResource(NotificationResource notificationResource) {
        notificationResourceRepository.delete(notificationResource);
    }

	public NotificationResource findNotificationResource(Long id) {
        return notificationResourceRepository.findOne(id);
    }

	public List<NotificationResource> findAllNotificationResources() {
        return notificationResourceRepository.findAll();
    }

	public List<NotificationResource> findNotificationResourceEntries(int firstResult, int maxResults) {
        return notificationResourceRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveNotificationResource(NotificationResource notificationResource) {
        notificationResourceRepository.save(notificationResource);
    }

	public NotificationResource updateNotificationResource(NotificationResource notificationResource) {
        return notificationResourceRepository.save(notificationResource);
    }
}
